package com.wuze.cloud.handler;

import com.wuze.cloud.context.UserContext;
import com.wuze.cloud.pojo.SysUserDO;
import com.wuze.cloud.request.SysFileChunkQuery;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: wuze
 * @description:
 * @date: 2023/03/16
 */
@Component
public class ImageHandler implements FileHandler {

    @Value("${file.accessPath}")
    private String accessPath;

    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public List<String> tags() {
        return Lists.newArrayList(".bmp",".jpg",".jpeg",".png",".gif");
    }

    @Override
    public String handler(SysFileChunkQuery fileDto) {
        SysUserDO user = UserContext.getUser();
        return accessPath+user.getUserName()+"/"+fileDto.getOpenKey()+fileDto.getSuffix();
    }
}
